//
//  SKUDetailOneCell.m
//  Tang
//
//  Created by 352324497@qq.com on 15/12/8.
//  Copyright © 2015年 352324497@qq.com. All rights reserved.
//

#import "SKUDetailOneCell.h"

@implementation SKUDetailOneCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self)
    {
        self.selectionStyle = NO;
        self.titleLabel = [[UILabel alloc]initWithFrame:CGRectMake(0, 10 * Kx6, KWidth, 30 * Kx6)];
        self.titleLabel.font = [UIFont systemFontOfSize:18 * Kx6];
        self.titleLabel.textAlignment = NSTextAlignmentCenter;
        self.titleLabel.textColor = [UIColor darkGrayColor];
        [self.contentView addSubview:_titleLabel];
        
        self.priceLabel = [[UILabel alloc]initWithFrame:CGRectMake(0, 40 * Kx6, KWidth, 30 * Kx6)];
        self.priceLabel.textColor = [UIColor redColor];
        self.priceLabel.textAlignment = NSTextAlignmentCenter;
        self.priceLabel.font = [UIFont systemFontOfSize:16 * Kx6];
        [self.contentView addSubview:_priceLabel];
        
        self.lineView = [[UIView alloc]initWithFrame:CGRectMake(10 * Kx6, 70 * Kx6,KWidth - 20 * Kx6, 0.3 * Kx6)];
        self.lineView.backgroundColor = [UIColor lightGrayColor];
        [self.contentView addSubview:_lineView];
        
        self.descLabel = [[UILabel alloc]initWithFrame:CGRectMake(10 * Kx6, 80 * Kx6, KWidth - 20 * Kx6, 20 * Kx6)];
        self.descLabel.numberOfLines = 0;
        self.descLabel.textColor = [UIColor lightGrayColor];
        self.descLabel.font = [UIFont systemFontOfSize:14 * Kx6];
        [self.contentView addSubview:_descLabel];
        
        self.photoArray = [NSMutableArray array];
    }
    return self;
}

-(void)setModel:(SKUDetailOneModel *)model
{
    _model = model;
    self.titleLabel.text = model.title;
    self.priceLabel.text = [NSString stringWithFormat:@"¥%@", model.price];
    self.descLabel.text = model.desc;
    if (model.desc.length == 0)
    {
        [self.lineView removeFromSuperview];
        self.descLabel.height = 0;
    }
    else{
        CGFloat height = [CallTool heightForNSStringWithString:model.desc width:KWidth - 20 * Kx6 fontSize:14 * Kx6 space:6];
        self.descLabel.height = height;
    }
    
}

+(CGFloat)heightForCellWithModel:(SKUDetailOneModel *)model
{
    if (model.desc.length == 0)
    {
        return 80 * Kx6;
    }
    else{
        CGFloat height = [CallTool heightForNSStringWithString:model.desc width:KWidth - 20 * Kx6 fontSize:14 * Kx6 space:6];
        return height + 90 * Kx6;
    }
}
/*
-(void)cycleScrollView:(SDCycleScrollView *)cycleScrollView didSelectItemAtIndex:(NSInteger)index
{
    NSLog(@"---点击了第%ld张图片", index);
    if (self.delegate && [self.delegate respondsToSelector:@selector(backSDCycleScrollViewWithIndex:)])
    {
        [self.delegate backSDCycleScrollViewWithIndex:index];
    }
}
*/

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
